package cc.comac.mom.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipFaultCauseService;
import cc.comac.mom.bean.EquipFaultCause;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.datahandlers.entity.EquipFaultCauseDataHandler;
import cc.comac.mom.util.ResultBean;

@Service
@RestController
public class EquipFaultCauseServiceImpl implements EquipFaultCauseService {

	@Autowired
	private EquipFaultCauseDataHandler equipFaultlCauseDataHandler;
	
	
	@Override
	public ResultBean insertFaultCause(@RequestBody EquipFaultCause equipFaultlCause) {
		
		return equipFaultlCauseDataHandler.insertFaultCause(equipFaultlCause);
	}

	@Override
	public ResultBean updateFaultCause(@RequestBody EquipFaultCause equipFaultlCause) {
		// TODO Auto-generated method stub
		ResultBean resultBean = new ResultBean(true);
		int updateFaultCause = equipFaultlCauseDataHandler.updateFaultCause(equipFaultlCause);
		resultBean.setObject(updateFaultCause);
		return resultBean;
	}

	@Override
	public ResultBean batchDelete(@RequestBody List<EquipFaultCause> list) {
		ResultBean resultBean = new ResultBean(true);
		boolean batchDelete = equipFaultlCauseDataHandler.batchDelete(list);
		resultBean.setObject(batchDelete);
		return resultBean;
	}

	@Override
	public ResultDev selectSomeField(@RequestBody EquipFaultCause equipFaultlCause) {
		ResultDev resuleDev = null;
		if (equipFaultlCause.getSearchAll() != 1) {
			resuleDev = equipFaultlCauseDataHandler.selectSomeField(equipFaultlCause);
		} else {
			resuleDev = equipFaultlCauseDataHandler.selectAll();
		}
		return resuleDev;
	}

	@Override
	public ResultDev selectAll() {
		// TODO Auto-generated method stub
		return equipFaultlCauseDataHandler.selectAll();
	}

}
